Example to get Facebook Events using sdk v4 from fan page into Wordpress site [on hold]

Posted by Dorshin on Stack Overflow See other posts from Stack Overflow or by Dorshin
Published on 2014-05-30T02:51:06Z Indexed on 2014/06/01 3:26 UTC
Read the original article Hit count: 699

Filed under:
|
|
|
|

Been trying to update to the new FB php sdk v4 for pulling events into my website, but having trouble finding how to do it.

I want to pull public event information from a FB "page" using their fan page ID number. For example, a venue that has multiple events.

What are the minimal classes I need to "require_once" and "use" to only pull the events (don't need to login)?

The site is on Wordpress which doesn't use sessions, so what do I do with the "session_start()" statement? Will it work anyway?

Could I get a basic code example of how to get the event info into an array? (I want to make sure I get the syntax correct)

So far I've got the below code, but it is not working.

session_start();

require_once( 'Facebook/GraphObject.php' );
require_once( 'Facebook/GraphSessionInfo.php' );
require_once( 'Facebook/FacebookSession.php' );
require_once( 'Facebook/FacebookCurl.php' );
require_once( 'Facebook/FacebookHttpable.php' );
require_once( 'Facebook/FacebookCurlHttpClient.php' );
require_once( 'Facebook/FacebookResponse.php' );
require_once( 'Facebook/FacebookSDKException.php' );
require_once( 'Facebook/FacebookRequestException.php' );
require_once( 'Facebook/FacebookAuthorizationException.php' );
require_once( 'Facebook/FacebookRequest.php' );
require_once( 'Facebook/FacebookRedirectLoginHelper.php' );

use Facebook\GraphSessionInfo;
use Facebook\FacebookSession;
use Facebook\FacebookCurl;
use Facebook\FacebookHttpable;
use Facebook\FacebookCurlHttpClient;
use Facebook\FacebookResponse;
use Facebook\FacebookAuthorizationException;
use Facebook\FacebookRequestException;
use Facebook\FacebookRequest;
use Facebook\FacebookSDKException;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\GraphObject;


function facebook_event_function() {

FacebookSession::setDefaultApplication('11111111111','00000000000000000');

/* make the API call */
$request = new FacebookRequest($session, '/{123456789}/events','GET');
$response = $request->execute();
$graphObject = $response->getGraphObject();

}

So far, not getting anything in the $graphObject and it's throwing this error as well:

PHP Fatal error:  Uncaught exception 'Facebook\FacebookAuthorizationException' with message '(#803) Some of the aliases you requested do not exist: v2.0GET' in ../Facebook/FacebookRequestException.php:134

After I get something in the $graphObject, I want to add the info to a DB table. This part I am OK on.

Thank you for the help.

© Stack Overflow or respective owner

Related posts about php

Related posts about facebook